<?php

//--------------------------------------------------
//	Filename: profile_new_cat.php
//--------------------------------------------------
if( !defined('IN_INDEX') )
{
	posterror("ACCESS DENIED", "This page is hidden.");
	exit;
}
if(!checkSession())
{
			function redirect($url)
			{
			?>
				<script type="text/javascript">
					{
					window.location = "<?=$url?>";
					}
				</script>
			<?php 
			}
			redirect("index.php?action=login");
	exit;
}
if(isset($_POST['add_cat_submit']))
{
	$catname = $_POST['catname'];
	
	$sql = "INSERT INTO " . TRAINING_CAT_TABLE . " SET ".
		"training_cat_name='" . $catname . "', ".
		"training_cat_user_id='" . $USER->getId() . "'";
	if(!$result = $db->sql_query($sql))
		{
			printError("SQL ERROR", mysql_error($sql));
		}
	else
	{
		echo"<br /><br /><br /><br /><br /><br /><br /><br /><br />
					<center><meta http-equiv='refresh' content='1;url=index.php?action=profile&sub=newt' />";
		echo "<h1>" . ucfirst(translate('category_added_successfully')) . "</h1>";
		echo "<br/>" . translate('redirectedin') . " <a href='index.php?action=profile&sub=newt>" . translate('clickhere') . "</a><div class='fixed'>
					</div>
				</div>
				</div>
			<div class='fixed'>
			</div>
			<div id='footer'>
			<a id='gotop' href='#' onclick='MGJS.goTop();return false;'>" . translate('top') . "</a>
				<div align='center' id='copyright'>&copy; " . translate('copyrightyear') . " " . translate('header_text'). " - " .  translate('curversion') ." - <a href='index.php?action=contact'>" . translate('contact') ."</a> - <a href='index.php?action=about'>" . translate('about') . "</a> - " . translate('onlineusers'). ": " . getActiveUsers() . "<br />
                </div></center>";
		exit;
			
	}	
}
?>

<div id='postpath'>
		<a title="<?php echo translate('gotofrontpage'); ?>" href="index.php"><?php echo translate('home'); ?></a>
        &gt; <a href="index.php?action=blogs" title='<?php echo translate('showallblogs'); ?>'><?php echo translate('blog'); ?></a> 
		&gt; <a href="index.php?action=profile&id=<?php echo $USER->getId(); ?>"><?php echo ucf($USER->getFirstname()) . " " . ucf($USER->getLastname()); ?></a>
        &gt; <a href="index.php?action=profile&sub=newt" title='<?php echo translate('addnewtraining'); ?>'><?php echo translate('addnewtraining'); ?></a> 
        &gt; <a href="index.php?action=profile&sub=new_cat" title='<?php echo translate('add_cat'); ?>'><?php echo translate('add_cat'); ?></a>
</div>

<br /><br />
<center>
<div id="respond">
<form name="comment" method="post" action="index.php?action=profile&sub=new_cat">
	<table>
    <h2><?php echo translate('add_cat'); ?></h2>
	<tr>
			<td>
				<input type="text" size="40" name="catname"></textarea>
			</td>
        
        	
            <td align="right">
            <input style="font-weight:bold;" align="right" type="submit" name="add_cat_submit" value=" <?php echo ucf(translate('add')); ?> ">
			</td>
 		</tr>
	</table>
</form>
</div>
</center>